<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Pagos</title>
    </head>
    <body>

        <ui:composition template="./../../resources/template/facesTemplate.xhtml">

            <ui:define name="content">
                <h:form id="frm">

                    <h:panelGroup rendered="#{pagoBean.agregar eq true or pagoBean.modificar eq true}">
                        <fieldset>
                            <div class="tablaForm">
                                <div class="fila">
                                    <div class="etiq"><label for="fecha">Fecha: </label></div>
                                    <div class="cont">
                                        <h:inputText value="#{pagoBean.pago.id}"/>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </h:panelGroup>
                    <h:panelGroup rendered="#{pagoBean.agregar eq false and pagoBean.modificar eq false}">
                        <fieldset>
                            <h3><h:outputText value="#{loginBean.ubicacion}"/></h3>
                            <table class="busqueda">
                                <tr>
                                    <td>
                                        <label for="idFiltro">Nº:</label>
                                        <h:inputText id="idFiltro" styleClass="d_num" value="#{pagoBean.idFiltro}"/>
                                    </td>
                                    <td colspan="2">
                                        <label for="clienteFiltro">Cliente: </label>
                                        <h:inputText id="clienteFiltro" value="#{pagoBean.pago.cliente}" size="50" maxlength="50"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="ventaFiltro">Venta:</label>
                                        <h:inputText id="ventaFiltro" styleClass="d_num" value="#{pagoBean.ventaFiltro}"/>
                                    </td>
                                    <td>
                                        <label for="activoFiltro">Activo: </label>
                                        <h:selectOneMenu value="#{pagoBean.activoFiltro}">
                                            <f:selectItem itemLabel="-SELECCIONAR-" itemValue="X"/>
                                            <f:selectItem itemLabel="Si" itemValue="S"/>
                                            <f:selectItem itemLabel="No" itemValue="N"/>
                                        </h:selectOneMenu>
                                    </td>
                                    <td>
                                        <label for="fechaUltimopagoFiltro">Fecha: </label>
                                        <rich:calendar value="#{pagoBean.pago.fecha}" id="fechaUltimopagoFiltro" enableManualInput="true"
                                                       popup="true" datePattern="dd/MM/yyyy"
                                                       resetTimeOnDateSelect="true">
                                            <rich:validator/>
                                        </rich:calendar>
                                    </td>
                                </tr>
                            </table>
                            <div class="botonera">
                                <h:commandButton id="btnBuscar" styleClass="submit" value="Buscar" action="#{pagoBean.buscar()}"/>
                                <h:commandButton styleClass="submit" value="Todos" action="#{pagoBean.todos}"/>
                            </div>
                        </fieldset>
                        <div class="mensajes">
                            <h:messages id="messages" errorClass="messageError" infoClass="messageInfo" warnClass="messageWarn"/>
                        </div>
                        <fieldset>
                            <h:panelGroup id="tabla">
                                <h:panelGroup rendered="#{not empty pagoBean.lista }">
                                    <table class="tablaDatos">
                                        <thead>
                                            <tr>
                                                <th width="2%"></th>
                                                <th width="5%">
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Id">
                                                            <f:setPropertyActionListener value="id" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'id'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                                <th>
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Cliente">
                                                            <f:setPropertyActionListener value="cliente" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'cliente'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                                <th width="5%">
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Venta">
                                                            <f:setPropertyActionListener value="venta" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'venta'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                                <th>
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Total Pagado">
                                                            <f:setPropertyActionListener value="totalPagado" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'totalPagado'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                                <th>
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Fecha">
                                                            <f:setPropertyActionListener value="fecha" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'fecha'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                                <th width="5%">
                                                    <p>
                                                        <h:commandLink action="#{pagoBean.listar}" value="Activo">
                                                            <f:setPropertyActionListener value="activo" target="#{pagoBean.facade.orden.columna}"/>
                                                            <f:setPropertyActionListener value="true" target="#{pagoBean.facade.orden.asc}"/>
                                                            <h:outputText value="#{(pagoBean.facade.orden.asc) ? '▲' : '▼'}"
                                                                          rendered="#{pagoBean.facade.orden.columna eq 'activo'}"/>
                                                        </h:commandLink>
                                                    </p>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <ui:repeat var="row" value="#{pagoBean.lista}">
                                                <tr>
                                                    <td><input type="radio" id="radio" name="radio" value="#{row.id}"/></td>
                                                    <td><h:outputText value="#{row.id}"/></td>
                                                    <td><h:outputText value="#{row.credito.transaccion.comprador.nombre}"/></td>
                                                    <td>
                                                        <h:commandLink value="#{row.credito.transaccion.id}" action="#{ventaMotosBean.resumenVenta(row.credito.transaccion.id)}"/>
                                                    </td>
                                                    <td><h:outputText value="#{row.totalPagado}">
                                                            <f:convertNumber pattern="#{pagoBean.monedaPattern}"/>
                                                        </h:outputText></td>
                                                    <td><h:outputText value="#{row.fecha}">
                                                            <f:convertDateTime pattern="#{pagoBean.fechaHoraPattern}" timeZone="#{loginBean.timeZone}"/>
                                                        </h:outputText></td>
                                                    <td>
                                                        <h:panelGroup rendered="#{row.activo eq 'S'}"><img src="../../resources/images/onebit_06.png" width="15"/></h:panelGroup>
                                                        <h:panelGroup rendered="#{row.activo eq 'N'}"><img src="../../resources/images/onebit_10.png" width="15"/></h:panelGroup>
                                                    </td>
                                                </tr>
                                            </ui:repeat>
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <td colspan="11">
                                                    <h:commandLink action="#{pagoBean.anterior}">Anterior</h:commandLink>
                                                    &#160;|&#160;#{pagoBean.facade.desde + 1}..#{pagoBean.facade.ultimo} de #{pagoBean.facade.contador}&#160;|&#160;
                                                    <h:commandLink action="#{pagoBean.siguiente}">Siguiente</h:commandLink>
                                                </td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </h:panelGroup>
                                <div class="botonera">
                                    <h:commandButton id="btnNuevo" value="Nuevo" action="#{pagoBean.nuevo}" styleClass="submit"/>
                                    <h:commandButton id="btnModificar" value="Modificar" action="#{pagoBean.modificar}" styleClass="submit" rendered="#{not empty pagoBean.lista }"/>
                                    <h:commandButton id="btnVerDetalle" value="Ver Detalle" action="#{pagoBean.verDetalle}" styleClass="submit" rendered="#{not empty pagoBean.lista }"/>
                                </div>
                            </h:panelGroup>
                        </fieldset>
                    </h:panelGroup>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>